import Vue from "vue";
import VueRouter from "vue-router";

//解决连续点击同个路由出bug
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
Vue.use(VueRouter);

const routes = [
  {
    path: "/home",
    name: "home",
    component: () => import('../views/Home/Home.vue')
  },
  {
    path: "/",
    redirect: '/home'
  },
  {
    path: "/list",
    name: "list",
    component: () => import('../views/List/List.vue')
  }, {
    path: "/help",
    name: "help",
    component: () => import('../views/Help/Help.vue')
  },
  {
    path: "/cart",
    name: "cart",
    component: () => import('../views/Cart/Cart.vue')
  }, {
    path: "/mine",
    name: "mine",
    component: () => import('../views/Mine/Mine.vue')
  },
  {
    path: "/reg",
    name: "reg",
    component: () => import('../views/Reg/Reg.vue'),
    meta: {//元信息
      ishide: true,
      name: '注册页'
    }
  },
  {
    path: "/login",
    name: "login",
    component: () => import('../views/Login/Login.vue'),
    meta: {
      ishide: true
    }
  },
  {
    path: "/detail",
    name: "detail",
    component: () => import('../views/Detail/Detail.vue'),
    meta: {
      ishide: true
    }
  },
];

const router = new VueRouter({
  routes
});

export default router;
